import { Todo } from "./model/todo";
import { Action } from "@ngrx/store";

export const ADD_TODO = 'ADD_TODO';
export const UPDATE_TODO = 'UPDATE_TODO';
export const DELETE_TODO = 'DELETE_TODO';
export const COMPLETE_TODO = 'COMPLETE_TODO';

export function addTodo(todo: Todo): Action {
  return {
    type: ADD_TODO,
    payload: todo
  }
}

export function completeTodo(todo: Todo): Action {
  return {
    type: COMPLETE_TODO,
    payload: todo
  }
}

export function deleteTodo(todo: Todo): Action {
  return {
    type: DELETE_TODO,
    payload: todo
  }
}

export const FILTER_ACTIONS = {
  All: 'FILTER_ALL',
  Complete: 'FILTER_COMPLETE',
  Pending: 'FILTER_PENDING'
}
export const FILTER_ALL = 'ALL'
export const FILTER_COMPLETE = 'COMPLETE'
export const FILTER_PENDING = 'PENDING'

export function filterTodo(cond): Action {
  return {
    type: FILTER_ACTIONS[ cond ]
  }
}
